package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishOverViewVO;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {
	Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

	//@Select("select * from dish where id = #{id}")
	DishVO getById(Long id);

	@AutoFill(value = OperationType.INSERT)
		//@Options(useGeneratedKeys = true, keyProperty = "id")
	void insert(Dish dish);

	@AutoFill(value = OperationType.UPDATE)
	void updateById(Dish dish);

	@Delete("delete from dish where id = #{id}")
	void deleteById(Long id);

	@Select("select count(id) from dish where category_id = #{id}")
	Integer countByCategoryId(Long id);

	//@AutoFill(value = OperationType.UPDATE)
	@Update("update dish set status = #{status} where id = #{id}")
	void startOrStop(Integer status, Long id);

	List<DishVO> list(Dish dish);

	Integer queryWithSetmealCountByIds(Long id);

	DishOverViewVO queryStatusCount();
}
